Expand description

const fn implementation of the SHA-3 family of hash and extendable-output functions.

This crate allows you to use the SHA-3 hash and extendable-output functions as constant expressions in Rust. For all other usages, the sha3 crate includes more optimized implementations of these hash functions.

Examples

const PSEUDO_RANDOM_BYTES: [u8; 1000] = Shake256::new()
        .update(b"The quick brown fox ")
        .update(b"jumps over the lazy dog")
        .finalize();
#![feature(const_mut_refs)]
const ROUND_CONSTANTS: [u128; 8] = {
    let shake = Shake128::new()
        .update(b"The quick brown fox ")
        .update(b"jumps over the lazy dog");

    let mut reader = shake.finalize_xof();
    let mut output = [0; 8];

    let mut i = 0;
    while i < 8 {
        let mut buf = [0; 16];
        reader.read(&mut buf);
        output[i] = u128::from_be_bytes(buf);
        i += 1;
    }

    output
};

assert_eq!(
    [
        324498722242859095401832112442782838951,
        100470442341479765851591908475476895342,
        241049111671168257801898223573666863059,
        139197826094415251816510671569090212218,
        73371475849610774600276735485442220492,
        321031806373587100556524628628207173306,
        70553598458795679727810425741185559539,
        297273966300911440566694043047331846682,
    ],
    ROUND_CONSTANTS,
);

Structs

The KECCAK-224 hash function
The KECCAK-256 hash function
The KECCAK-384 hash function
The KECCAK-512 hash function
The SHA3-224 hash function
The SHA3-256 hash function
The SHA3-384 hash function
The SHA3-512 hash function
The SHAKE128 extendable-output function
The SHAKE256 extendable-output function